﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DevTool.Contraner
{
    public partial class ZhenZheControl : UserControl
    {
        public ZhenZheControl()
        {
            InitializeComponent();
        }
        private void txt_change()
        {
            var input = this.txt_bd.Text;
            var txt = this.richText_txt.Text;
            if (!string.IsNullOrEmpty(input))
            {
                try
                {
                    int i = 0; this.richTextBox_result.Clear();
                    MatchCollection mc = Regex.Matches(txt, input, RegexOptions.IgnoreCase | RegexOptions.Singleline);                   
                    foreach (Match m in mc)
                    {
                        if (string.IsNullOrEmpty(m.Value))
                        {
                            continue;
                        }
                        i++;
                        if (i <= 100)
                        {                            
                            this.richTextBox_result.AppendText("匹配内容[" + i + "]：" + m.Value+"\r\n");
                        }
                        else
                        {
                            break;
                        }

                    }
                }
                catch (Exception)
                {
                }
            }
            else
            {
                this.richTextBox_result.Text = "匹配值";
            }

        }
        private void txt_bd_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                txt_change();
            }
           
        }

        private void richText_txt_TextChanged(object sender, EventArgs e)
        {
            txt_change();
        }

        private void txt_bd_TextChanged(object sender, EventArgs e)
        {
            txt_change();
        }
    }
}
